package com.workcell.workdata.xthings.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.workcell.workdata.common.core.util.R;
import com.workcell.workdata.common.log.annotation.SysLog;
import com.workcell.workdata.common.security.annotation.Inner;
import com.workcell.workdata.xthings.entity.TempBoard;
import com.workcell.workdata.xthings.service.TempBoardService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.access.prepost.PreAuthorize;
import com.workcell.workdata.common.excel.annotation.ResponseExcel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 临时报表地址
 *
 * @author 廖博文
 * @date 2023-02-23 10:02:16
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/tempboard" )
@Api(value = "tempboard", tags = "临时报表地址管理")
public class TempBoardController {

    private final  TempBoardService tempBoardService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param tempBoard 临时报表地址
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getTempBoardPage(Page page, TempBoard tempBoard) {
        return R.ok(tempBoardService.page(page, Wrappers.query(tempBoard)));
    }

    /**
     * 通过id查询临时报表地址
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(tempBoardService.getById(id));
    }

    /**
     * 新增临时报表地址
     * @param tempBoard 临时报表地址
     * @return R
     */
    @ApiOperation(value = "新增临时报表地址", notes = "新增临时报表地址")
    @PostMapping
    public R save(@RequestBody TempBoard tempBoard) {
        return R.ok(tempBoardService.save(tempBoard));
    }

    /**
     * 修改临时报表地址
     * @param tempBoard 临时报表地址
     * @return R
     */
    @ApiOperation(value = "修改临时报表地址", notes = "修改临时报表地址")
    @PutMapping
    public R updateById(@RequestBody TempBoard tempBoard) {
        return R.ok(tempBoardService.updateById(tempBoard));
    }

    /**
     * 通过id删除临时报表地址
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除临时报表地址", notes = "通过id删除临时报表地址")
    @DeleteMapping("/{id}" )
    public R removeById(@PathVariable Long id) {
        return R.ok(tempBoardService.removeById(id));
    }

}
